package com.bhs.controller;

import com.bhs.pojo.Item;
import com.bhs.pojo.MainMenu;
import com.bhs.pojo.Menu;
import com.bhs.pojo.TopMenu;
import com.bhs.service.Menu.LeftMenuService;
import com.bhs.service.Menu.TopMenuService;
import com.bhs.vo.ResponseData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/menu")
public class MenuController {
    @Autowired
    private TopMenuService topMenuService;
    @Autowired
    private LeftMenuService leftMenuService;

    // 获取顶部菜单数据
    @GetMapping("/getTopMenu")
    public ResponseData getTopMenu() {
        List<TopMenu> topMenu = topMenuService.findTopMenu();
        return ResponseData.success(topMenu);
    }

    // 获取顶部商品列表
    @GetMapping("/getTopMenuItem/{id}")
    public ResponseData getTopMenuItem(@PathVariable("id") Integer id) {
        List<Item> topItemList = topMenuService.findTopItem(id);
        return ResponseData.success(topItemList);
    }

    // 获取左侧菜单数据
    @PostMapping("/getLeftMenu")
    public ResponseData getLeftMenu() {
        List<Menu> leftMenuList = leftMenuService.getLeftMenu();
        return ResponseData.success(leftMenuList);
    }

    // 获取左侧商品数据
    @PostMapping("/getLeftItemList/{id}")
    public ResponseData getLeftItemList(@PathVariable("id") Integer id) {
        List<Item> leftItemList = leftMenuService.getLeftItemList(id);
        return ResponseData.success(leftItemList);
    }
//     获取主要的商品列表
    @PostMapping("/getAllItemList")
    public ResponseData getAllItemList(){
        List<MainMenu> allItemList = leftMenuService.getAllItemList();
        return ResponseData.success(allItemList);
    }

}
